<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="getBtn">get(查询)</button>
    <button id="postBtn">post(添加)</button>
    <button id="deleteBtn">delete(删除)</button>
    <button id="putBtn">put(修改)</button>

    <br>

    <div>
        <label>姓名</label>
        <input id="stuname" type="text"/>
        <button id='getNameBtn'>根据名字查询</button>
    </div>
    
</body>
<script src="./lib/jquery.min.js"></script>
<script>
//js代码
$("#getBtn").on("click",function () {
    $.ajax({
        type:"get",
        url:"/student/10",
        dataType:"json",
        success:(data)=>{
            console.log(data);
        }    
    })
    
})

$("#postBtn").on("click",function () {
    $.ajax({
        type:"post",
        url:"/student/10086",
        dataType:"json",
        success:(data)=>{
            console.log(data);
        }    
    })
    
})

$("#deleteBtn").on("click",function () {
    $.ajax({
        type:"delete",
        url:"/student/18888",
        dataType:"json",
        success:(data)=>{
            console.log(data);
        }    
    })
    
})

$("#putBtn").on("click",function () {
    $.ajax({
        type:"put",
        url:"/student/666/888",
        dataType:"json",
        success:(data)=>{
            console.log(data);
        }    
    })
    
})

  //根据名字查询
  $("#getNameBtn").click(()=>{
       $.ajax({
        type:"get",
        url:"/getstudentbyName/"+$("#stuname").val(),
        dataType:"json",
        success:(data)=>{
             console.log(data);
        }

       })
   })


</script>
</html>